﻿using System;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using LFloatMath.Math;

namespace IQIGame.Onigao.Logic
{
    public class SkillEffective_WeaknessHit : SkillEffective
    {
        protected override ISerializeCustomPOD OnExecute(SkillEffectiveData data, Unit target, SkillEffectiveContext context, int effectiveIndex, out SkillEffectiveResponse startResp)
        {
            startResp = null;
            this.Execute(target, context);
            return null;
        }

        protected override ISerializeCustomPOD OnActionExecute(SkillEffectiveData data, SkillActionNode action, Unit target, ref SkillEffectiveContext context, int effectiveIndex)
        {
            this.Execute(target, context);
            return null;
        }

        private void Execute(Unit rTarget, SkillEffectiveContext rContext)
        {
            var rAttacker = rContext.skill.executer;
            var rSkill = rContext.skill;
            var rDamageType = (EDamageType)(1 << rSkill.config.DamageType);
            DamageController.TakeWeaknessHit(rAttacker, rTarget, rDamageType, rSkill.config.WeaknessHit);
        }

#if UNITY_EDITOR
        public override string ToString(SkillCustomConfig config)
        {
            return $"造成弱点击破";
        }
#endif
    }
}